package com.atguigu.staservice.schedule;


import com.atguigu.staservice.service.StatisticsDailyService;
import com.atguigu.staservice.utils.DateUtil;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author He Wentao
 * @since 2022/10/4 17:32
 */

@Component
public class ScheduledTask {

    @Resource
    StatisticsDailyService service;

    @Scheduled(cron = "0 0 1 * * ?")
    public void RecordDate(){
        // 获取昨天的日期
        String day = DateUtil.formatDate(DateUtil.addDays(new Date(),-1));
        service.countRegister(day);
    }

}
